//
//  ViewController.m
//  06-UINavigationController
//
//  Created by 冀永金 on 16/7/21.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "VCOfSecond.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 1.设置navigationBar的属性
    self.navigationItem.title = @"我是标题，呵呵呵";
    
    // 字体颜色
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    //2.标题视图
//    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"dog",@"cat"]];
//    // 标题视图，修改 x,y对视图没有影响
//   seg.frame = CGRectMake(0, 0, 200, 44);
//    
 //
   // self.navigationItem.titleView = seg;
    //
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:nil];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:nil];
    // 5.
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"dd" style:UIBarButtonItemStylePlain target:self action:nil];
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:nil];
    self.navigationItem.leftBarButtonItems = @[item,item1];
    //6. rightBarButtonItems  1--2个item 为最优
    //7. YES 为隐藏   NO 不隐藏   默认NO
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.hidden = NO;
    // 8.style为枚举    默认Default
    self.navigationController.navigationBar.accessibilityNavigationStyle = UIBarStyleDefault;
    // 9. navigationBar的  Bar 颜色
   // self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    //10.tintColor
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    //11.translucent 管理半透明效果 YES 为开启  NO为关闭
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.view addSubview:button];
    button.frame = CGRectMake(0,0 , 200, 100);
    button.backgroundColor = [UIColor blueColor];
    [button addTarget:self action:@selector(handleNext:) forControlEvents:UIControlEventTouchUpInside];
    // 设置为YES时 self.view 坐标系从原点开始
    // 设置为NO时  self.view  从navigationBar 下开始
    
    //self.navigationController.navigationBar.translucent = NO;
    
    //13.改变坐标系效果与translucent为NO一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    // 页面跳转
    // 1.push 入栈
    // 2.pop 出栈
    // 3.viewController存放navigationController里所有的控制器
    // 4.topViewController 栈顶视图控制器（最后入栈）
    // 5.visibleVIewController 可见视图控制器
    
    // 返回指定控制器
   //   self.navigationController popToViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>
    
    // 返回根视图控制器
    
  //  self.navigationController popToRootViewControllerAnimated:<#(BOOL)#>
    
    // 返回上一个控制器
  //  self.navigationController popViewControllerAnimated:<#(BOOL)#>
    
    
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)handleNext:(UIButton *)button {
    VCOfSecond *second = [[VCOfSecond alloc]init];
    [self.navigationController pushViewController:second animated:YES];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
